package com.github.slprj.slake.net;

/**
 * Des:
 * rpc网络通信数据结构
 *
 * @author cp
 * @date 2022/8/23 9:02
 */
public abstract class Frame {
    /**
     * 数据index
     */
    public static final int IDX_TYPE = 1;
    public static final int IDX_COMMAND = 2;
    public static final int IDX_SEQ = 3;
    public static final int IDX_RESP_CODE = 4;
    public static final int IDX_MSG = 5;
    public static final int IDX_BODY = 15;

    /**
     * 请求/返回
     * @see FrameType
     */
    protected int frameType;
    /**
     * 请求命令
     */
    protected int command;
    protected int seq;
    /**
     * 返回code
     */
    protected int respCode;
    protected String msg;

    @Override
    public String toString() {
        String sb = "Frame(type=" + frameType +
                ",cmd=" + command +
                ",seq=" + seq +
                ",respCode=" + respCode +
                ")";
        return sb;
    }

    public int getFrameType() {
        return frameType;
    }

    public void setFrameType(int frameType) {
        this.frameType = frameType;
    }

    public int getCommand() {
        return command;
    }

    public void setCommand(int command) {
        this.command = command;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    public int getRespCode() {
        return respCode;
    }

    public void setRespCode(int respCode) {
        this.respCode = respCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
